<!--阅读及点赞-->
<template>
  <section class="foot-views">
    <span v-if="this.flagType===2">播放量 {{preData.views}}</span>
    <span v-if="this.flagType===1">阅读量 {{preData.views}}</span>
    <!--<span>收藏：{{preData.views}}</span>-->
    <span class="action">点赞量 {{preData.ups || 0}} <!--<i @click="up" class="icon icon-like" :class="{'icon-liked': hasUp}"></i>--></span>
  </section>
</template>

<script>
  export default {
    name: '',
    components: {},
    data () {
      return {
        data: {
          ups: 0
        },
        contentId: '',
        hasUp: false,
        flagType: 1
      }
    },
    created () {
      this.preData = this.$store.state.newsDetail
      this.flagType = this.$store.state.flagType
      if (this.$store.state.newsDetail.detail) {
        this.hasUp = this.$store.state.newsDetail.detail.upOrDown
      }
    },
    methods: {
      up () {
        if (this.hasUp === true) {
          return false
        }
        let params = {
          contentId: this.contentId || this.preData.id,
          type: 1
        }
        return this.fetchService.newsUpsAndDowns(params).then(res => {
          if (res.code !== 0) {
            return this.tools.tip(res.message || '接口服务出错，请联系管理员')
          }
//          this.tools.tip('点赞成功!')
          this.hasUp = true
          this.preData.ups ++
          return res
        })
      }
    }
  }
</script>

<style scoped lang="scss">
  @import "@/common/stylus/moon.scss";
  .foot-views {
    color:#666;
    display:flex;
    justify-content: space-between;
    align-items:center;
    padding:20px 20px;
    margin:0;
    background:$border-color;
    border-radius:10px;
    font-size:13PX;
    .action {
      display:flex;
      justify-content: space-between;
      align-items:center;
    }
    .icon {
      margin-left:20px;
      display:inline-block;
      width:32px;
      height:32px;
      background:url('../../../static/images/dangjian/home/news/icon-like.png') no-repeat center;
      background-size: 100% 100%;
      position: relative;
      &.icon-liked {background-image: url("../../../static/images/dangjian/home/news/icon-like-active.png");}
    }
  }
</style>
